﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.Diagnostics.Logging;
using YasharEl.Infrastructure.ResourcesManagement.Managers;
using YasharEl.Infrastructure.ResourcesManagement.Managers.Xml;
using YasharEl.Infrastructure.ResourcesManagement.Configuration;

namespace YasharEl.Infrastructure.ResourcesManagement.Providers
{
    /// <summary>
    /// Xml Resource Provider.
    /// </summary>
    /// <remarks>
    /// This provider loads a binary resource file and generates a <see cref="ExtendedComponentResourceManager" /> populated
    /// with resources from the binary file.
    /// </remarks>
    //[ConfigurationElementType(typeof(XmlResourceProviderData))]
    public class XmlResourceProvider : FileResourceProvider
    {
        #region Constructors

        /// <summary>
        /// Initializes a new default instance of the <see cref="XmlResourceProvider"/> class.
        /// </summary>
        /// <param name="resourcePathName">Name of the resource path.</param>
        /// <param name="resourceBaseName">Name of the resource base.</param>
        public XmlResourceProvider(string resourcePathName, string resourceBaseName, ILogger<ResourceProvider> logger)
            : base(resourcePathName, resourceBaseName, logger)
        {
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Creates the file resource manager.
        /// </summary>
        /// <returns>
        /// instance of the file resource manager type
        /// </returns>
        protected override ExtendedComponentResourceManager CreateFileResourceManager(string resourcePathName, string resourceBaseName)
        {
            return new XmlResourceManager(resourcePathName, resourceBaseName);
        }

        /// <summary>
        /// Gets the file resource extension.
        /// </summary>
        /// <returns>extension without the separator</returns>
        protected override string FindFileResourceExtension()
        {
            var xmlResourceProviderConfig = new XmlResourceProviderConfig();

            return xmlResourceProviderConfig.XmlExtension;
        }

        #endregion
    }
}
